package src

import (
	"lutai/src/api"
	"lutai/src/bll"
	"lutai/src/service/db"

	"github.com/teambition/gear"
)

func newRouter(db *db.DB) (router *gear.Router) {
	router = gear.NewRouter(gear.RouterOptions{
		Root:              "/api",
		IgnoreCase:        true,
		FixedPathRedirect: true,
	})

	blls := new(bll.All).Init(db)

	testAPI := new(api.Test).Init(blls)

	// test
	router.Get("/test", testAPI.Query)
	router.Get("/test/:id", testAPI.Get)
	router.Post("/test", testAPI.Create)
	router.Put("/test/:id", testAPI.Update)
	router.Delete("/test/:id", testAPI.Delete)

	packetAPI := new(api.Packet).Init(blls)
	// packets
	router.Get("/packet/page", packetAPI.QueryPage)
	router.Get("/packet/:id", packetAPI.QueryData)

	geographyAPI := new(api.Geography).Init(blls)
	// geography
	router.Get("/geography", geographyAPI.Query)
	return
}
